test: property-check plugin health classification and report shape#596
test: property-check plugin health classification and report shape#596ndycode wants to merge 2 commits into
Conversation
Three fast-check properties over getAccountHealth/formatHealthReport: - counts and status derive exactly from the per-account classification for any pool (timestamps straddling now, undefined fallbacks, health 0..100): healthy iff not rate-limited, not cooling, health >= 50, circuit closed; status partitions empty->healthy, none->unhealthy, some->degraded, all->healthy - an open circuit disqualifies an otherwise perfect account: tripping the account:<index> fallback breaker for any subset is reflected in circuitState, subtracted from healthyAccountCount, and drives the status partition - the formatted report names every account with its health percentage and exactly the flags its classification implies, and the summary lines appear iff their counts are nonzero Companion to the property suites in #574/#575/#592-#595. https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Warning Review limit reached
More reviews will be available in 20 minutes. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile flagged two coverage gaps: the half-open state was unreachable without advancing the clock, and accounts sharing an email silently shared a breaker without an explicit contract. Property 2 now probes open -> half-open under fake timers (both states disqualify, and the report renders the precise circuit flag), pool emails are unique by construction, and a dedicated property pins shared-email accounts to one breaker while distinct emails stay isolated - derived through the same getAccountIdentityKey the SUT uses. https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Summary
lib/health.ts— the pure shape-transformation behindcodex-multi-authhealth reporting (AUDIT-M08/D-04 documents it as deliberately decoupled from the manager, which makes it an exact-oracle target).What Changed
New
test/property/health.property.test.ts(3 properties overgetAccountHealth/formatHealthReport, circuit registry cleared per iteration sincegetAccountHealthreads the module-level breakers):nowso both sides of the rate-limit/cooldown comparisons generate;undefinedexercising the?? 0fallbacks; health 0–100), every per-account flag, all three counts, and the status partition derive exactly from the documented rule: healthy ⇔ not rate-limited ∧ not cooling ∧health >= 50∧ circuit closed. The status edges are pinned too — an empty pool readshealthy, zero healthy of some readsunhealthy, anything between readsdegraded.account:<index>fallback breaker (3 failures) for any subset of identity-less accounts shows up incircuitState, disqualifies otherwise-perfect accounts fromhealthyAccountCount, and drives the status partition.formatHealthReportnames every account (email or theAccount Nfallback) with its health percentage and exactly the flags its classification implies, and theRate Limited:/Cooling Down:summary lines appear iff their counts are nonzero.No SUT bugs found.
Validation
npm test -- test/property/health.property.test.ts test/health.test.ts— 17/17 (new 3 + existing 14 untouched)npm run typecheck(also via pre-commit hook)npx eslint test/property/health.property.test.ts --max-warnings=0clearCircuitBreakers()in before/afterEach and at each property iteration startDocs and Governance Checklist
Risk and Rollback
test/property/suites.https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Generated by Claude Code
note: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
additive test-only pr adding
test/property/health.property.test.ts, a 4-property fast-check suite forlib/health.ts'sgetAccountHealthandformatHealthReport. no sut code is touched.healthy ⇔ not rate-limited ∧ not cooling ∧ health ≥ 50 ∧ circuit closed).openandhalf-opendisqualification viavi.useFakeTimers()+canExecute()forcing the transition, closing the gap flagged in the prior review round.Rate Limited:/Cooling Down:summary lines. per-account line format for circuit-flagged accounts is not exercised in property 4 (see inline comment).Confidence Score: 5/5
safe to merge — additive test file only, no sut or production code changes
the change is a single new test file with no modifications to lib/ or any other production code. module-state hygiene is handled correctly via clearCircuitBreakers() in before/afterEach and at each property iteration start. the half-open path, previously unexercised, is now covered with proper fake-timer discipline and a finally-block cleanup. the only gap is a minor coverage omission in property 4 (circuit flag per-account line format), which does not affect production correctness.
test/property/health.property.test.ts — the report-shape property could be strengthened to cover per-account lines that include circuit flags
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[arbAccounts generator] --> P1[property 1: classification oracle] A --> P4[property 4: report shape] P2_arb[fc.integer count\nfc.uniqueArray trippedRaw\nfc.boolean probeHalfOpen] --> P2[property 2: circuit integration] P2 -->|probeHalfOpen=false| OPEN[circuits stay open\nexpectedState = 'open'] P2 -->|probeHalfOpen=true & tripped>0| HALF[vi.setSystemTime + canExecute\nexpectedState = 'half-open'] FC_BOOL[fc.boolean shareEmail] --> P3[property 3: email aliasing] P1 --> SUT1[getAccountHealth accounts NOW] P4 --> SUT1 P2 --> SUT1 P3 --> SUT1 SUT1 --> SUT2[formatHealthReport] SUT1 --> ASSERT_COUNTS[assert counts + status partition] SUT2 --> ASSERT_REPORT[assert per-account lines + summary flags] P2 --> ASSERT_CIRCUIT[assert circuitState per account\nassert healthyAccountCount\nassert report.includes circuit-state]Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "test: exercise half-open disqualificatio..." | Re-trigger Greptile